<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html class="loginHtml">
<head>
	
	<meta charset="utf-8">
	<title>系统登录</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../css/login.css" media="all" />
</head>
<script type="text/javascript">

</script>
<body class="loginBody">
	<form class="layui-form" id="loginForm" method="post" action="">
		<div class="login-title">用户登录</div>
		<div class="layui-form-item input-item layui-input-active">
			<label class="layadmin-user-login-icon layui-icon layui-icon-username" for="userName">用户名</label>
			<input type="text" placeholder="登录用户名" autocomplete="off" name="loginId" id="user_name"  class="layui-input" lay-verify="required" >
		</div>
		<div class="layui-form-item input-item layui-input-active">
			<label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password">密码</label>
			<input type="password" placeholder="登录密码" autocomplete="off" id="user_password"  name="loginPwd" class="layui-input" lay-verify="required" >
		</div>
		<!-- 验证码 -->
		<div class="layui-form-item input-item layui-input-active">
          <div class="layui-row">
            <div class="layui-col-xs7">
              <label class="layadmin-user-login-icon layui-icon layui-icon-vercode" for="LAY-user-login-vercode">验证码</label>
              <input type="text" name="varify" id="varify" lay-verify="required" placeholder="图形验证码" class="layui-input">
            </div>
            <div class="layui-col-xs5">
              <div style="margin-left: 10px;">
                <img src="../safecode.do" class="layadmin-user-login-codeimg" id="LAY-user-get-vercode" style="width:100px;">
              </div>
            </div>
          </div>
        </div>
		
		<div class="layui-form-item input-item layui-input-active">
			<span style="font-family: STSong;color: red;" id="showinput"></span>
		</div>
		<div class="layui-form-item">
			<button type="button" id ="login-button" class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
		</div>
	</form>
	<script type="text/javascript" src="../layui/layui.js"></script>
	<script src="../js/jquery-3.3.1.js" charset="utf-8"></script>
	<script src="../lib/md5.js" charset="utf-8"></script>
	<script src="../lib/systempublickey.js" charset="utf-8"></script>
	
	<script>
		layui.use(['form','layer'], function(){
			var layer = layui.layer
			var form = layui.form;	  
			var $ = layui.jquery;
			
			/* 点击登录 ,用jquery判断输入的用户名、密码是否符合条件*/
			$("#login-button").click(function(){
				var username=$("#user_name").val().trim();
				var password=$("#user_password").val().trim();
				var varify=$("#varify").val().trim();
		
				if(username==null || username=="" || username==undefined){
					$("#user_name").focus();
					return;
				}
				if(password==null || password=="" || password==undefined){
					$("#user_password").focus();
					return;
				}
				if(varify==null || varify=="" || varify==undefined){
					$("#varify").focus();
					return;
				}
				if(password.length<6 || password.length>18){
					layer.alert('密码长度不符合规范!', {icon: 2});
					return;
				}
				
				/* 用MD5将密码做加密处理 */
				var enpwd = hex_md5(fix(username,password));
				$("#user_password").val(enpwd);
				var param = '?userid='+username+'&pwd='+enpwd +'&varify='+varify;//参数组合
				alert(enpwd);
				var index = layer.load(0, {shade: 0.1});
				//alert(1);
				$.ajax({
					type : 'get',
					url : '../admin/adminuserlogin'+param,
					datatype : 'json',
					success : function(data) {
						if (data.code == 10001) {
							
							//window.location.href = "index.jsp";
							document.getElementById("showinput").innerText = data.msg;
							setTimeout("javascript:location.href='index.jsp'", 0);
							
						} else {
							//layer.alert(data.msg, {icon: 2});
							layer.close(index);
							document.getElementById("showinput").innerText = data.msg;
						}
					},
					error:function(){
	    	        	//layer.alert(data.msg, {icon: 2});
	    	        	document.getElementById("showinput").innerText = data.msg;
	    	        }
				});
			});
				
			
		});
	</script>
</body>
</html>
